﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAL;
public class AdvertiseDAL
{
    /// <summary>
    /// 查询广告
    /// </summary>
    /// <returns></returns>
    public Advertise Get(string key)
    {
        Tools tool = new Tools();
        tool.AddSqlParameter("key", SqlDbType.VarChar, key);
        DataTable tb = SqlHelper.ExecuteGetTable(DBManager.WebSite, System.Data.CommandType.StoredProcedure, "GetAdvertiseByKey", tool.GetSqlParameters());
        Advertise a = null;
        if (tb.Rows.Count > 0)
        {
            DataRow row = tb.Rows[0];
            a = new Advertise();
            a.AdvertiseId = Tools.GetString(row["AdvertiseId"]);
            a.Content = Tools.GetString(row["content"]);
            a.Link = Tools.GetString(row["link"]);
        }
        return a;
    }
    /// <summary>
    /// 修改
    /// </summary>
    /// <param name="a"></param>
    /// <returns></returns>
    public int Update(Advertise a)
    {
        Tools tool = new Tools();
        tool.AddSqlParameter("AdvertiseId", SqlDbType.VarChar, 30, a.AdvertiseId);
        tool.AddSqlParameter("content", SqlDbType.VarChar, a.Content);
        tool.AddSqlParameter("link", SqlDbType.VarChar, a.Link);
        int resut = SqlHelper.ExecuteNonQuery(DBManager.WebSite, System.Data.CommandType.StoredProcedure, "UpdateAdvertise", tool.GetSqlParameters());
        return resut;
    }
}
